<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>理赔列表</title>
    <link rel="stylesheet" href="/adminthemes/layui/css/layui.css" media="all">
    <!-- jQuery -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<br>
<br>
<div class="demoTable" style="margin-left: 5%">
    被保险养殖场名称：
    <div class="layui-inline">
        <input style="width: 300px" class="layui-input" name="id" id="demoReload" autocomplete="off" placeholder="请输入被保险养殖场名称">
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
</div>
<table id="demo"  lay-data="{id:'demo'}" lay-filter="test" style="margin-left: 20%;margin-right: 20%"></table>
</body>
<script src="/adminthemes/layui/layui.js"></script>
<script src="/adminthemes/layui/layDate-v5.0.9/laydate/laydate.js"></script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        //第一个实例
        table.render({
            elem: '#demo'
            ,height: 315
            ,limit:10
            ,id:"rbt"
            ,request: {
                pageName: 'page1' //页码的参数名称，默认：page
                ,limitName: 'limit1'//每页数据量的参数名，默认：limit
            }
            ,url: '/web/supplier/getClaimList.do' //数据接口
            ,page: true //开启分页
            ,cols: [[ //表头
                {field: 'claim_number', title: '理赔单号', width:200}
                ,{field: 'item', title: '保险标的', width:150}
                ,{field: 'amount', title: '理赔数量', width:100}
                ,{field: 'fromal_number', title: '保单号码', width:200}
                ,{field: 'breed_factory_name', title: '被保险养殖场', width: 150}
               ,{field: 'case_date', title: '出险日期', width: 150,templet: '<div>{{ layui.laytpl.toDateString(d.case_date) }}</div>'}
                ,{field: 'check_status', title: '状态', width: 80,toolbar: '#status'}
                   ,{field: 'caozuo', title: '操作', width: 150,toolbar: '#barDemo'}
//                ,{field: 'score', title: '评分', width: 80, sort: true}
//                ,{field: 'classify', title: '职业', width: 80}toolbar: '#barDemo'
//                ,{field: 'wealth', title: '财富', width: 135, sort: true}
            ]]
        });


        var $ = layui.$, active = {
            reload: function(){
                var demoReload = $('#demoReload').val();
                //执行重载
                table.reload('rbt', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        seacher: demoReload
                    }
                });
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                // layer.msg('ID：'+ data.id + ' 的查看操作');
                layer.open({
                    type: 2,
                    area: ['830px', '550px'],
                    skin: 'layui-layer-lan',
                    content: '/admin/insurance/getClaimDetail.do?id='+data.id,
                })
            }
        });


        //时间戳的处理
        layui.laytpl.toDateString = function(d, format){
            var date = new Date(d || new Date())
                ,ymd = [
                this.digit(date.getFullYear(), 4)
                ,this.digit(date.getMonth() + 1)
                ,this.digit(date.getDate())
            ]
                ,hms = [
                this.digit(date.getHours())
                ,this.digit(date.getMinutes())
                ,this.digit(date.getSeconds())
            ];

            // format = format || 'yyyy-MM-dd HH:mm:ss';
            format = format || 'yyyy-MM-dd';
            return format.replace(/yyyy/g, ymd[0])
                .replace(/MM/g, ymd[1])
                .replace(/dd/g, ymd[2])
                .replace(/HH/g, hms[0])
                .replace(/mm/g, hms[1])
                .replace(/ss/g, hms[2]);
        };

        //数字前置补零
        layui.laytpl.digit = function(num, length, end){
            var str = '';
            num = String(num);
            length = length || 2;
            for(var i = num.length; i < length; i++){
                str += '0';
            }
            return num < Math.pow(10, length) ? str + (num|0) : num;
        };
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="detail">查看详情</a>
</script>
<script type="text/html" id="status">
    {{#  if(d.check_status== 0){ }}
    <p>待审核</p>
    {{#  } }}
    {{#  if(d.check_status== 1){ }}
    <p>现场查勘</p>
    {{#  } }}
    {{#  if(d.check_status== 2){ }}
    <p>已完成</p>
    {{#  } }}
    {{#  if(d.check_status== 3){ }}
    <p>不受理</p>
    {{#  } }}
</script>
</body>
</html>